import 'package:clock_notification/pages/map.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';

import '../pages/location.dart';

class LocationApp extends StatefulWidget {
  const LocationApp({super.key});

  @override
  State<LocationApp> createState() => _LocationAppState();
}

class _LocationAppState extends State<LocationApp> {
  Function function = () {};
  final String _test = "hello";

  // location data
  var locationMessage = '';



  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("location services"),
        // 添加=
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            const Icon(
              Icons.location_on,
              size: 46,
              color: Colors.blue,
            ),
            const SizedBox(
              height: 10.0,
            ),
            const Text(
              "Get user location",
              style: TextStyle(fontSize: 26.0, fontWeight: FontWeight.bold),
            ),
            const SizedBox(
              height: 20.0,
            ),
            Text(locationMessage),
            TextButton(
              // onPressed: () {} ,
              onPressed: () {
                // getCurLocation();
                // setState(() {
                //   locationMessage = "aaa2";
                // });
                Navigator.push(context,
                    MaterialPageRoute(builder: (context) => const MapPage()));
              },
              style: ButtonStyle(
                backgroundColor: MaterialStateProperty.all(Colors.blue),
              ),
              child: const Text(
                "user get map",
                style: TextStyle(
                    color: Colors.white, fontWeight: FontWeight.bold),
              ),
            ),
            TextButton(
              // onPressed: () {} ,
              onPressed: () {
                // getCurLocation();
                // setState(() {
                //   locationMessage = "aaa2";
                // });
                Navigator.push(context,
                    MaterialPageRoute(builder: (context) => const GaoDeLocationPage()));
              },
              style: ButtonStyle(
                backgroundColor: MaterialStateProperty.all(Colors.blue),
              ),
              child: const Text(
                "高德接口",
                style: TextStyle(
                    color: Colors.white, fontWeight: FontWeight.bold),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
